package com.online.customerchatserver.thread;

import com.online.customerchatserver.entity.Message;

import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * Created by littleheng on 2018/5/2
 */
public class ThreadLock {

    //  顾客发送的消息集合
    public static Map<String, Message> messagesMap = new ConcurrentHashMap<String, Message>();

    //  坐席发送的消息集合
    public static Map<String, Message> agentMessagesMap = new ConcurrentHashMap<String, Message>();

    //  坐席已读的消息uuid和企业id
    public static Queue<List<Object>> uuidsQueue = new ConcurrentLinkedQueue<List<Object>>();

    private static boolean isLock = false;

    public synchronized boolean getOprLock() {
        if (isLock) {
            return false;
        }
        isLock = true;
        return isLock;
    }

    public synchronized void unOprLock() {
        isLock = false;
    }

}